﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
        <style type="text/css">
            body { color: InactiveCaptionText; }
            h2 { font-size: 120%; color: CaptionText; }
        </style>
    </head>
	<body>
	    <h2>Switch Statements</h2>
	    <p>A <strong>switch</strong> statement is a bit more complex, but not that much.</p>
	    <p>The Case() extension method adds cases, and the Do() extension method adds a statement block to the last added case (or default).</p>
        <h2>Source:</h2>
        <style type="text/css">
        .cf { font-family: Courier New; font-size: 10pt; color: black; background: white; }
        .cl { margin: 0px; }
        .cb1 { color: blue; }
        .cb2 { color: #2b91af; }
        .cb3 { color: #a31515; }
        </style>
        <div class="cf">
        <pre class="cl"><span class="cb1">return</span> <span class="cb2">JS</span>.Switch(<span class="cb2">JS</span>.Id(<span class="cb3">&quot;event&quot;</span>))</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; .Case(<span class="cb3">&quot;click&quot;</span>)</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; .Case(<span class="cb3">&quot;contextmenu&quot;</span>).Do(</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">JS</span>.Alert(<span class="cb3">&quot;clicked!&quot;</span>),</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">JS</span>.Break())</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; .Case(<span class="cb3">&quot;enter&quot;</span>).Do(</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">JS</span>.Alert(<span class="cb3">&quot;entered&quot;</span>),</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">JS</span>.Break())</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; .Case(<span class="cb3">&quot;leave&quot;</span>).Do(</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">JS</span>.Alert(<span class="cb3">&quot;leave&quot;</span>),</pre>
        <pre class="cl">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span class="cb2">JS</span>.Break());</pre>
        </div>        
    </body>
</html>
